<!DOCTYPE html><html xmlns:date="http://exslt.org/dates-and-times" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta charset="utf-8">
<title>Plurious Framework » \framework\library\authentication\Auth</title>
<meta name="author" content="Mike van Riel">
<meta name="description" content="">
<link href="../css/template.css" rel="stylesheet" media="all">
<script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script><script src="../js/jquery-ui-1.8.2.custom.min.js" type="text/javascript"></script><script src="../js/jquery.mousewheel.min.js" type="text/javascript"></script><script src="../js/bootstrap.js" type="text/javascript"></script><script src="../js/template.js" type="text/javascript"></script><script src="../js/prettify/prettify.min.js" type="text/javascript"></script><link rel="shortcut icon" href="../img/favicon.ico">
<link rel="apple-touch-icon" href="../img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="../img/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="../img/apple-touch-icon-114x114.png">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner"><div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></a><a class="brand" href="../index.html">Plurious Framework</a><div class="nav-collapse"><ul class="nav">
<li class="dropdown">
<a href="#api" class="dropdown-toggle" data-toggle="dropdown">
                                    API Documentation <b class="caret"></b></a><ul class="dropdown-menu">
<li><a>Namespaces</a></li>
<li><a href="../namespaces/framework.html"><i class="icon-th"></i> framework</a></li>
<li><a href="../namespaces/global.html"><i class="icon-th"></i> global</a></li>
<li><a href="../namespaces/plurious.html"><i class="icon-th"></i> plurious</a></li>
</ul>
</li>
<li class="dropdown" id="charts-menu">
<a href="#charts" class="dropdown-toggle" data-toggle="dropdown">
                                    Charts <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="../graph_class.html"><i class="icon-list-alt"></i> Class hierarchy diagram</a></li></ul>
</li>
<li class="dropdown" id="reports-menu">
<a href="#reports" class="dropdown-toggle" data-toggle="dropdown">
                                    Reports <b class="caret"></b></a><ul class="dropdown-menu">
<li><a href="../errors.html"><i class="icon-remove-sign"></i> Errors 
                <span class="label label-info">439</span></a></li>
<li><a href="../markers.html"><i class="icon-map-marker"></i> Markers 
                <ul><li>todo 
                <span class="label label-info">82</span>
</li></ul></a></li>
<li><a href="../deprecated.html"><i class="icon-stop"></i> Deprecated elements 
                <span class="label label-info">0</span></a></li>
</ul>
</li>
</ul></div>
</div></div>
<div class="go_to_top"><a href="#___" style="color: inherit">Back to top  <i class="icon-upload icon-white"></i></a></div>
</div>
<div id="___" class="container">
<noscript><div class="alert alert-warning">
                            Javascript is disabled; several features are only available
                            if Javascript is enabled.
                        </div></noscript>
<div class="row">
<div class="span4">
<span class="btn-group visibility" data-toggle="buttons-checkbox"><button class="btn public active" title="Show public elements">Public</button><button class="btn protected" title="Show protected elements">Protected</button><button class="btn private" title="Show private elements">Private</button><button class="btn inherited active" title="Show inherited elements">Inherited</button></span><div class="btn-group view pull-right" data-toggle="buttons-radio">
<button class="btn details" title="Show descriptions and method names"><i class="icon-list"></i></button><button class="btn simple" title="Show only method names"><i class="icon-align-justify"></i></button>
</div>
<ul class="side-nav nav nav-list">
<li class="nav-header">
<i class="icon-custom icon-method"></i> Methods</li>
<li class="method public "><a href="#__construct" title="__construct :: Builds all the necessary preliminary components required for the
athentiation process."><span class="description">Builds all the necessary preliminary components required for the
athentiation process.</span><pre>__construct()</pre></a></li>
<li class="method public "><a href="#authenticate" title="authenticate :: Authenticate a user"><span class="description">Authenticate a user</span><pre>authenticate()</pre></a></li>
<li class="method public inherited"><a href="#delete" title="delete :: Sends a DELETE query to the PDO object."><span class="description">Sends a DELETE query to the PDO object.</span><pre>delete()</pre></a></li>
<li class="method public "><a href="#findUserMatches" title="findUserMatches :: Checks the database (final authority) to find all users with the given
username (should only be one)"><span class="description">Checks the database (final authority) to find all users with the given
username (should only be one)</span><pre>findUserMatches()</pre></a></li>
<li class="method public "><a href="#findUserMatchesNiceName" title="findUserMatchesNiceName :: Checks the database (final authority) to find all users with the given
nice name"><span class="description">Checks the database (final authority) to find all users with the given
nice name</span><pre>findUserMatchesNiceName()</pre></a></li>
<li class="method public inherited"><a href="#get" title="get :: Sends a SELECT query to the PDO object."><span class="description">Sends a SELECT query to the PDO object.</span><pre>get()</pre></a></li>
<li class="method public "><a href="#getUserId" title="getUserId :: Retrieves the user id for a given username"><span class="description">Retrieves the user id for a given username</span><pre>getUserId()</pre></a></li>
<li class="method public inherited"><a href="#insert" title="insert :: Sends an INSERT query to the PDO object."><span class="description">Sends an INSERT query to the PDO object.</span><pre>insert()</pre></a></li>
<li class="method public "><a href="#isAuthenticated" title="isAuthenticated :: Checks the user's authentication status upon a revisit to the site"><span class="description">Checks the user's authentication status upon a revisit to the site</span><pre>isAuthenticated()</pre></a></li>
<li class="method public "><a href="#isUserLocked" title="isUserLocked :: Checks the database (final authority) to see if a user is locked"><span class="description">Checks the database (final authority) to see if a user is locked</span><pre>isUserLocked()</pre></a></li>
<li class="method public "><a href="#last_activity" title="last_activity :: Sets a new date for the latest activity"><span class="description">Sets a new date for the latest activity</span><pre>last_activity()</pre></a></li>
<li class="method public "><a href="#lockUser" title="lockUser :: Lock the user account."><span class="description">Lock the user account.</span><pre>lockUser()</pre></a></li>
<li class="method public "><a href="#logout" title="logout :: Logs the user out and redirects them as appropriate"><span class="description">Logs the user out and redirects them as appropriate</span><pre>logout()</pre></a></li>
<li class="method public "><a href="#match_unique_ids" title="match_unique_ids :: Returns all records with unique IDs"><span class="description">Returns all records with unique IDs</span><pre>match_unique_ids()</pre></a></li>
<li class="method public inherited"><a href="#query" title="query :: Generic PDO Query method."><span class="description">Generic PDO Query method.</span><pre>query()</pre></a></li>
<li class="method public "><a href="#requireAuthentication" title="requireAuthentication :: Forces one of two choices: 1."><span class="description">Forces one of two choices: 1.</span><pre>requireAuthentication()</pre></a></li>
<li class="method public inherited"><a href="#save" title="save :: Sends an INSERT query to the PDO object."><span class="description">Sends an INSERT query to the PDO object.</span><pre>save()</pre></a></li>
<li class="method public inherited"><a href="#select" title="select :: Sends a SELECT query to the PDO object."><span class="description">Sends a SELECT query to the PDO object.</span><pre>select()</pre></a></li>
<li class="method public inherited"><a href="#selectCols" title="selectCols :: Sends a SELECT query to the PDO object."><span class="description">Sends a SELECT query to the PDO object.</span><pre>selectCols()</pre></a></li>
<li class="method public inherited"><a href="#set" title="set :: Sends an INSERT query to the PDO object."><span class="description">Sends an INSERT query to the PDO object.</span><pre>set()</pre></a></li>
<li class="method public inherited"><a href="#setOrder" title="setOrder :: Sets the Column and Direction for sort operations."><span class="description">Sets the Column and Direction for sort operations.</span><pre>setOrder()</pre></a></li>
<li class="method public inherited"><a href="#update" title="update :: SQL UPDATE Abstraction"><span class="description">SQL UPDATE Abstraction</span><pre>update()</pre></a></li>
<li class="method public "><a href="#updateUserLastLogin" title="updateUserLastLogin :: Sets a new date for the latest login in time"><span class="description">Sets a new date for the latest login in time</span><pre>updateUserLastLogin()</pre></a></li>
<li class="nav-header private">» Private</li>
<li class="method private "><a href="#changePassword" title="changePassword :: "><span class="description">changePassword()
        </span><pre>changePassword()</pre></a></li>
<li class="method private "><a href="#generateSeed" title="generateSeed :: Generate a new seed (nonce) to be used for authentication."><span class="description">Generate a new seed (nonce) to be used for authentication.</span><pre>generateSeed()</pre></a></li>
<li class="method private "><a href="#getValidationData" title="getValidationData :: Fetches the 'remember me' cookie and the session user data so they can
be validated"><span class="description">Fetches the 'remember me' cookie and the session user data so they can
be validated</span><pre>getValidationData()</pre></a></li>
<li class="method private "><a href="#hashPassword" title="hashPassword :: "><span class="description">hashPassword()
        </span><pre>hashPassword()</pre></a></li>
<li class="method private "><a href="#serverCert" title="serverCert :: Validates that the data in the session right now is the same as
the data that was in the session on the previous visit."><span class="description">Validates that the data in the session right now is the same as
the data that was in the session on the previous visit.</span><pre>serverCert()</pre></a></li>
<li class="method private "><a href="#storeWrite" title="storeWrite :: Upon successful login, writes the user data to the session and creates
the 'remember me' cookie if requested."><span class="description">Upon successful login, writes the user data to the session and creates
the 'remember me' cookie if requested.</span><pre>storeWrite()</pre></a></li>
<li class="method private "><a href="#updateAttempts" title="updateAttempts :: We test for repeated bad attempts and strike them down if they exceed the
limit set in the config."><span class="description">We test for repeated bad attempts and strike them down if they exceed the
limit set in the config.</span><pre>updateAttempts()</pre></a></li>
<li class="method private "><a href="#validatePassword" title="validatePassword :: "><span class="description">validatePassword()
        </span><pre>validatePassword()</pre></a></li>
<li class="nav-header">
<i class="icon-custom icon-property"></i> Properties</li>
<li class="nav-header protected">» Protected</li>
<li class="property protected "><a href="#%24config" title="$config :: The Config Object reference"><span class="description">The Config Object reference</span><pre>$config</pre></a></li>
<li class="property protected inherited"><a href="#%24db" title="$db :: Holds instance of the PDO Abstraction class chain"><span class="description">Holds instance of the PDO Abstraction class chain</span><pre>$db</pre></a></li>
<li class="property protected "><a href="#%24document" title="$document :: The Document Object reference"><span class="description">The Document Object reference</span><pre>$document</pre></a></li>
<li class="property protected "><a href="#%24nicenameCol" title="$nicenameCol :: Name of the nicename column name from the configuration"><span class="description">Name of the nicename column name from the configuration</span><pre>$nicenameCol</pre></a></li>
<li class="property protected "><a href="#%24passwordCol" title="$passwordCol :: Name of the password column name from the configuration"><span class="description">Name of the password column name from the configuration</span><pre>$passwordCol</pre></a></li>
<li class="property protected "><a href="#%24session" title="$session :: The Session Object reference"><span class="description">The Session Object reference</span><pre>$session</pre></a></li>
<li class="property protected "><a href="#%24useridCol" title="$useridCol :: Name of the User ID column name from the configuration"><span class="description">Name of the User ID column name from the configuration</span><pre>$useridCol</pre></a></li>
<li class="property protected "><a href="#%24usernameCol" title="$usernameCol :: Name of the username column name from the configuration"><span class="description">Name of the username column name from the configuration</span><pre>$usernameCol</pre></a></li>
<li class="nav-header private">» Private</li>
<li class="property private "><a href="#%24auth_table" title="$auth_table :: Name of the database table used for authentication"><span class="description">Name of the database table used for authentication</span><pre>$auth_table</pre></a></li>
<li class="property private inherited"><a href="#%24order_by_col" title="$order_by_col :: Holds Column name for sorting operations"><span class="description">Holds Column name for sorting operations</span><pre>$order_by_col</pre></a></li>
<li class="property private inherited"><a href="#%24order_direction" title="$order_direction :: Holds sorting direction (ASC, DESC) for sorting operations"><span class="description">Holds sorting direction (ASC, DESC) for sorting operations</span><pre>$order_direction</pre></a></li>
</ul>
</div>
<div class="span8">
<a name="%5Cframework%5Clibrary%5Cauthentication%5CAuth" id="\framework\library\authentication\Auth"></a><ul class="breadcrumb">
<li>
<a href="../index.html"><i class="icon-custom icon-class"></i></a><span class="divider">\</span>
</li>
<li><a href="../namespaces/framework.html">framework</a></li>
<span class="divider">\</span><li><a href="../namespaces/framework.library.html">library</a></li>
<span class="divider">\</span><li><a href="../namespaces/framework.library.authentication.html">authentication</a></li>
<li class="active">
<span class="divider">\</span><a href="../classes/framework.library.authentication.Auth.html">Auth</a>
</li>
</ul>
<div href="../classes/framework.library.authentication.Auth.html" class="element class">
<p class="short_description">Auth Class</p>
<div class="details">
<p class="long_description"><p>Features:
* Authenticates across multiple applications. Single sign-on.
* 3 Authentication methods
* Validates a nonce and regenerates on every attempt
* Uses an encrypted server-certificate to validate session data
with returning user
* Removes Session Fixation vulnerabilities. Regenerates session IDs on
significant changes to user authentication profile as well as after
configured number of site visits.
* Locks user account after configured missed attempt count</p>

<p>The class can authenticate with any one of three methods.  A traditional
plain text method classically used with SSL connections, a method similar
to captcha that is referred to here as unCaptcha since it takes remarkably
different approach, and the third is through the use of a hashed password
that is hashed on the client.</p>

<p>Authentication and Authorization for Plurious</p></p>
<table class="table table-bordered">
<tr>
<th>author</th>
<td><a href="mailto:randy@plurious.com">Randy Casburn</a></td>
</tr>
<tr>
<th>copyright</th>
<td>Copyright Plurious Software, all rights reserved</td>
</tr>
<tr>
<th>license</th>
<td><a href="http://opensource.org/licenses/MIT">MIT</a></td>
</tr>
<tr>
<th>license</th>
<td><a href="http://www.opensource.org/licenses/mit-license.html">http://www.opensource.org/licenses/mit-license.html</a></td>
</tr>
<tr>
<th>link</th>
<td><a href="http://plurious.com/framework/documentation/classes/Front.html">http://plurious.com/framework/documentation/classes/Front.html</a></td>
</tr>
<tr>
<th>version</th>
<td>2.1</td>
</tr>
<tr>
<th>uses</th>
<td>\framework\library\Model</td>
</tr>
<tr>
<th>uses</th>
<td>\framework\Front</td>
</tr>
<tr>
<th>uses</th>
<td>\framework\helper\UnCaptcha</td>
</tr>
<tr>
<th>used_by</th>
<td>\framework\library\access_control\User</td>
</tr>
</table>
<h3>
<i class="icon-custom icon-method"></i> Methods</h3>
<a name="__construct" id="__construct"></a><div class="element clickable method public __construct" data-toggle="collapse" data-target=".__construct .collapse">
<h2>Builds all the necessary preliminary components required for the
athentiation process.</h2>
<pre>__construct() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="authenticate" id="authenticate"></a><div class="element clickable method public authenticate" data-toggle="collapse" data-target=".authenticate .collapse">
<h2>Authenticate a user</h2>
<pre>authenticate(string $username, string $hash) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$username</h4>
<code>string</code><p>The username to authenticate</p></div>
<div class="subelement argument">
<h4>$hash</h4>
<code>string</code><p>the password to authenticate (may or may not be a hash</p>
</div>
</div></div>
</div>
<a name="delete" id="delete"></a><div class="element clickable method public delete" data-toggle="collapse" data-target=".delete .collapse">
<h2>Sends a DELETE query to the PDO object.</h2>
<pre>delete(\framework\library\type $table, array $where) : int</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>Passes query to PDO Abstraction Class DELETE Method</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::delete()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>\framework\library\type</code><p>The Table name to delete rows from</p></div>
<div class="subelement argument">
<h4>$where</h4>
<code>array</code><p>The WHERE clause (cannot be empty)</p>
</div>
<h3>Returns</h3>
<div class="subelement response">
<code>int</code>Number of deleted rows</div>
</div></div>
</div>
<a name="findUserMatches" id="findUserMatches"></a><div class="element clickable method public findUserMatches" data-toggle="collapse" data-target=".findUserMatches .collapse">
<h2>Checks the database (final authority) to find all users with the given
username (should only be one)</h2>
<pre>findUserMatches(string $username) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>If no parameter provided, searches for the current user</p></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$username</h4>
<code>string</code><p>The username to search</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>Associative array of all records matching search</div>
</div></div>
</div>
<a name="findUserMatchesNiceName" id="findUserMatchesNiceName"></a><div class="element clickable method public findUserMatchesNiceName" data-toggle="collapse" data-target=".findUserMatchesNiceName .collapse">
<h2>Checks the database (final authority) to find all users with the given
nice name</h2>
<pre>findUserMatchesNiceName(string $nicename) : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>If no parameter provided, searches for the current user</p></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$nicename</h4>
<code>string</code><p>The nice name to search</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>Associative array of all records matching search</div>
</div></div>
</div>
<a name="get" id="get"></a><div class="element clickable method public get" data-toggle="collapse" data-target=".get .collapse">
<h2>Sends a SELECT query to the PDO object.</h2>
<pre>get(string $table, array $where, int $limit) : array</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This query is synonymous with the select() method.</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::get()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>The Table to query</p></div>
<div class="subelement argument">
<h4>$where</h4>
<code>array</code><p>The WHERE clause equivilance</p></div>
<div class="subelement argument">
<h4>$limit</h4>
<code>int</code><p>The return limit</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>Associative array of DB results</div>
</div></div>
</div>
<a name="getUserId" id="getUserId"></a><div class="element clickable method public getUserId" data-toggle="collapse" data-target=".getUserId .collapse">
<h2>Retrieves the user id for a given username</h2>
<pre>getUserId(string $username) : mixed</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$username</h4>
<code>string</code><p>The username to get the id of</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>mixed</code>Returns boolean false if user not found or user ID otherwise</div>
</div></div>
</div>
<a name="insert" id="insert"></a><div class="element clickable method public insert" data-toggle="collapse" data-target=".insert .collapse">
<h2>Sends an INSERT query to the PDO object.</h2>
<pre>insert(string $table, array $data) : int</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This method is synonymous with set() &amp; save() methods</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::insert()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>Table to insert into</p></div>
<div class="subelement argument">
<h4>$data</h4>
<code>array</code><p>Data to insert</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>int</code>ID of inserted row</div>
</div></div>
</div>
<a name="isAuthenticated" id="isAuthenticated"></a><div class="element clickable method public isAuthenticated" data-toggle="collapse" data-target=".isAuthenticated .collapse">
<h2>Checks the user's authentication status upon a revisit to the site</h2>
<pre>isAuthenticated() : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Returns</h3>
<div class="subelement response">
<code>boolean</code>True=is authenticated</div>
</div></div>
</div>
<a name="isUserLocked" id="isUserLocked"></a><div class="element clickable method public isUserLocked" data-toggle="collapse" data-target=".isUserLocked .collapse">
<h2>Checks the database (final authority) to see if a user is locked</h2>
<pre>isUserLocked(string $username) : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$username</h4>
<code>string</code><p>Any username</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>boolean</code>True=Locked</div>
</div></div>
</div>
<a name="last_activity" id="last_activity"></a><div class="element clickable method public last_activity" data-toggle="collapse" data-target=".last_activity .collapse">
<h2>Sets a new date for the latest activity</h2>
<pre>last_activity() : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>todo</th>
<td>Needs to be updated to reflect new API</td>
</tr></table>
<h3>Returns</h3>
<div class="subelement response">
<code>boolean</code>True=record updated successfully</div>
</div></div>
</div>
<a name="lockUser" id="lockUser"></a><div class="element clickable method public lockUser" data-toggle="collapse" data-target=".lockUser .collapse">
<h2>Lock the user account.</h2>
<pre>lockUser(string $username) : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$username</h4>
<code>string</code>
</div>
<h3>Returns</h3>
<div class="subelement response">
<code>boolean</code>True=record updated successfully</div>
</div></div>
</div>
<a name="logout" id="logout"></a><div class="element clickable method public logout" data-toggle="collapse" data-target=".logout .collapse">
<h2>Logs the user out and redirects them as appropriate</h2>
<pre>logout(string $redirectTo) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$redirectTo</h4>
<code>string</code><p>a URL to redirect to upon logout</p></div>
</div></div>
</div>
<a name="match_unique_ids" id="match_unique_ids"></a><div class="element clickable method public match_unique_ids" data-toggle="collapse" data-target=".match_unique_ids .collapse">
<h2>Returns all records with unique IDs</h2>
<pre>match_unique_ids() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>Associative array of all records with unique IDs</div>
</div></div>
</div>
<a name="query" id="query"></a><div class="element clickable method public query" data-toggle="collapse" data-target=".query .collapse">
<h2>Generic PDO Query method.</h2>
<pre>query(string $sql, array $data) : mixed</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>User must supply complete SQL statement.</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::query()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$sql</h4>
<code>string</code><p>The SQL statement to execute</p></div>
<div class="subelement argument">
<h4>$data</h4>
<code>array</code><p>The data for the query</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>mixed</code>Array if SELECT, otherwise affected rows</div>
</div></div>
</div>
<a name="requireAuthentication" id="requireAuthentication"></a><div class="element clickable method public requireAuthentication" data-toggle="collapse" data-target=".requireAuthentication .collapse">
<h2>Forces one of two choices: 1.</h2>
<pre>requireAuthentication(string $url) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>be authenticated to continue or 2. redirect
away from the secure resource area.</p></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$url</h4>
<code>string</code><p>URL to redirec to if not authenticated</p></div>
</div></div>
</div>
<a name="save" id="save"></a><div class="element clickable method public save" data-toggle="collapse" data-target=".save .collapse">
<h2>Sends an INSERT query to the PDO object.</h2>
<pre>save(string $table, array $data) : int</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This method is synonymous with insert() method</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::save()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>Table to insert into</p></div>
<div class="subelement argument">
<h4>$data</h4>
<code>array</code><p>Data to insert</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>int</code>ID of inserted row</div>
</div></div>
</div>
<a name="select" id="select"></a><div class="element clickable method public select" data-toggle="collapse" data-target=".select .collapse">
<h2>Sends a SELECT query to the PDO object.</h2>
<pre>select(string $table, array $where, int $limit) : array</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This query is synonymous with the select() method.</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::select()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>The Table to query</p></div>
<div class="subelement argument">
<h4>$where</h4>
<code>array</code><p>The WHERE clause equivilance</p></div>
<div class="subelement argument">
<h4>$limit</h4>
<code>int</code><p>The return limit</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>Associative array of DB results</div>
</div></div>
</div>
<a name="selectCols" id="selectCols"></a><div class="element clickable method public selectCols" data-toggle="collapse" data-target=".selectCols .collapse">
<h2>Sends a SELECT query to the PDO object.</h2>
<pre>selectCols(string $table, array $cols, array $where, int $limit) : array</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This query is synonymous with the select() method.</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::selectCols()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>The Table to query</p></div>
<div class="subelement argument">
<h4>$cols</h4>
<code></code>
</div>
<div class="subelement argument">
<h4>$where</h4>
<code>array</code><p>The WHERE clause equivilance</p></div>
<div class="subelement argument">
<h4>$limit</h4>
<code>int</code><p>The return limit</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>Associative array of DB results</div>
</div></div>
</div>
<a name="set" id="set"></a><div class="element clickable method public set" data-toggle="collapse" data-target=".set .collapse">
<h2>Sends an INSERT query to the PDO object.</h2>
<pre>set(string $table, array $data) : int</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This method is synonymous with insert() method</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::set()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>Table to insert into</p></div>
<div class="subelement argument">
<h4>$data</h4>
<code>array</code><p>Data to insert</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>int</code>ID of inserted row</div>
</div></div>
</div>
<a name="setOrder" id="setOrder"></a><div class="element clickable method public setOrder" data-toggle="collapse" data-target=".setOrder .collapse">
<h2>Sets the Column and Direction for sort operations.</h2>
<pre>setOrder(string $col, string $dir) </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>NOTE: you must reset these parameters when finished with them. Otherwise
all results following will be sorted using these criteria.</p>

<p>To clear the sort criteria simply call this method with
no parameters passed -- setOrder();</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::setOrder()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$col</h4>
<code>string</code><p>The name of the column to sort results on</p></div>
<div class="subelement argument">
<h4>$dir</h4>
<code>string</code><p>Should be ASC or DESC</p></div>
</div></div>
</div>
<a name="update" id="update"></a><div class="element clickable method public update" data-toggle="collapse" data-target=".update .collapse">
<h2>SQL UPDATE Abstraction</h2>
<pre>update(array $new_values, string $table, array $where) : int</pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>Passes query to PDO Abstraction Class UPDATE Method</p></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::update()</td>
</tr></table>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$new_values</h4>
<code>array</code><p>The data used for the update</p></div>
<div class="subelement argument">
<h4>$table</h4>
<code>string</code><p>Name of the table to query</p></div>
<div class="subelement argument">
<h4>$where</h4>
<code>array</code><p>The WHERE clause</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>int</code>Number of affected rows</div>
</div></div>
</div>
<a name="updateUserLastLogin" id="updateUserLastLogin"></a><div class="element clickable method public updateUserLastLogin" data-toggle="collapse" data-target=".updateUserLastLogin .collapse">
<h2>Sets a new date for the latest login in time</h2>
<pre>updateUserLastLogin(string $username) : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$username</h4>
<code>string</code>
</div>
<h3>Returns</h3>
<div class="subelement response">
<code>boolean</code>True=record updated successfully</div>
</div></div>
</div>
<a name="changePassword" id="changePassword"></a><div class="element clickable method private changePassword" data-toggle="collapse" data-target=".changePassword .collapse">
<h2>changePassword()
        </h2>
<pre>changePassword($password) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$password</h4>
<code></code>
</div>
</div></div>
</div>
<a name="generateSeed" id="generateSeed"></a><div class="element clickable method private generateSeed" data-toggle="collapse" data-target=".generateSeed .collapse">
<h2>Generate a new seed (nonce) to be used for authentication.</h2>
<pre>generateSeed() </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>returns</th>
<td>a new seed</td>
</tr></table>
</div></div>
</div>
<a name="getValidationData" id="getValidationData"></a><div class="element clickable method private getValidationData" data-toggle="collapse" data-target=".getValidationData .collapse">
<h2>Fetches the 'remember me' cookie and the session user data so they can
be validated</h2>
<pre>getValidationData() : array</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>This is part of the 'remember me' functionality</p></p>
<h3>Returns</h3>
<div class="subelement response">
<code>array</code>The data to validate</div>
</div></div>
</div>
<a name="hashPassword" id="hashPassword"></a><div class="element clickable method private hashPassword" data-toggle="collapse" data-target=".hashPassword .collapse">
<h2>hashPassword()
        </h2>
<pre>hashPassword($password, $salt) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$password</h4>
<code></code>
</div>
<div class="subelement argument">
<h4>$salt</h4>
<code></code>
</div>
</div></div>
</div>
<a name="serverCert" id="serverCert"></a><div class="element clickable method private serverCert" data-toggle="collapse" data-target=".serverCert .collapse">
<h2>Validates that the data in the session right now is the same as
the data that was in the session on the previous visit.</h2>
<pre>serverCert(array $data) : boolean</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>It also validates
that the current user credentials belong to the same session currently
being used.</p></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$data</h4>
<code>array</code><p>Holds the previous CRC check and session data needed to recalulate the verification</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>boolean</code>to indicate if the test passed</div>
</div></div>
</div>
<a name="storeWrite" id="storeWrite"></a><div class="element clickable method private storeWrite" data-toggle="collapse" data-target=".storeWrite .collapse">
<h2>Upon successful login, writes the user data to the session and creates
the 'remember me' cookie if requested.</h2>
<pre>storeWrite(array $user) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>Also stores all user data as Obj properties.</p></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$user</h4>
<code></code>
</div>
</div></div>
</div>
<a name="updateAttempts" id="updateAttempts"></a><div class="element clickable method private updateAttempts" data-toggle="collapse" data-target=".updateAttempts .collapse">
<h2>We test for repeated bad attempts and strike them down if they exceed the
limit set in the config.</h2>
<pre>updateAttempts(int $result) : int</pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"><p>We'll use session flash to keep track of this.
The incrementing of the counter actually happens in the _store_write method where
the session information is updated.</p></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$result</h4>
<code>int</code><p>a success or failure mode to test against</p></div>
<h3>Returns</h3>
<div class="subelement response">
<code>int</code>the success or failure mode to tested against</div>
</div></div>
</div>
<a name="validatePassword" id="validatePassword"></a><div class="element clickable method private validatePassword" data-toggle="collapse" data-target=".validatePassword .collapse">
<h2>validatePassword()
        </h2>
<pre>validatePassword($password) </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<h3>Parameters</h3>
<div class="subelement argument">
<h4>$password</h4>
<code></code>
</div>
</div></div>
</div>
<h3>
<i class="icon-custom icon-property"></i> Properties</h3>
<a name="%24config" id="$config"> </a><div class="element clickable property protected $config" data-toggle="collapse" data-target=".$config .collapse">
<h2>The Config Object reference</h2>
<pre>$config </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24db" id="$db"> </a><div class="element clickable property protected $db" data-toggle="collapse" data-target=".$db .collapse">
<h2>Holds instance of the PDO Abstraction class chain</h2>
<pre>$db </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::$$db</td>
</tr></table>
</div></div>
</div>
<a name="%24document" id="$document"> </a><div class="element clickable property protected $document" data-toggle="collapse" data-target=".$document .collapse">
<h2>The Document Object reference</h2>
<pre>$document </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24nicenameCol" id="$nicenameCol"> </a><div class="element clickable property protected $nicenameCol" data-toggle="collapse" data-target=".$nicenameCol .collapse">
<h2>Name of the nicename column name from the configuration</h2>
<pre>$nicenameCol </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24passwordCol" id="$passwordCol"> </a><div class="element clickable property protected $passwordCol" data-toggle="collapse" data-target=".$passwordCol .collapse">
<h2>Name of the password column name from the configuration</h2>
<pre>$passwordCol </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24session" id="$session"> </a><div class="element clickable property protected $session" data-toggle="collapse" data-target=".$session .collapse">
<h2>The Session Object reference</h2>
<pre>$session </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24useridCol" id="$useridCol"> </a><div class="element clickable property protected $useridCol" data-toggle="collapse" data-target=".$useridCol .collapse">
<h2>Name of the User ID column name from the configuration</h2>
<pre>$useridCol </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24usernameCol" id="$usernameCol"> </a><div class="element clickable property protected $usernameCol" data-toggle="collapse" data-target=".$usernameCol .collapse">
<h2>Name of the username column name from the configuration</h2>
<pre>$usernameCol </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24auth_table" id="$auth_table"> </a><div class="element clickable property private $auth_table" data-toggle="collapse" data-target=".$auth_table .collapse">
<h2>Name of the database table used for authentication</h2>
<pre>$auth_table </pre>
<div class="labels"></div>
<div class="row collapse"><div class="detail-description"><p class="long_description"></p></div></div>
</div>
<a name="%24order_by_col" id="$order_by_col"> </a><div class="element clickable property private $order_by_col" data-toggle="collapse" data-target=".$order_by_col .collapse">
<h2>Holds Column name for sorting operations</h2>
<pre>$order_by_col </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::$$order_by_col</td>
</tr></table>
</div></div>
</div>
<a name="%24order_direction" id="$order_direction"> </a><div class="element clickable property private $order_direction" data-toggle="collapse" data-target=".$order_direction .collapse">
<h2>Holds sorting direction (ASC, DESC) for sorting operations</h2>
<pre>$order_direction </pre>
<div class="labels"><span class="label">Inherited</span></div>
<div class="row collapse"><div class="detail-description">
<p class="long_description"></p>
<table class="table table-bordered"><tr>
<th>inherited_from</th>
<td>\framework\library\Model::$$order_direction</td>
</tr></table>
</div></div>
</div>
</div>
</div>
</div>
</div>
<div class="row"><footer class="span12">
            Template is built using <a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap 2</a> and icons provided by <a href="http://glyphicons.com/">Glyphicons</a>.<br>
            Documentation is powered by <a href="http://www.phpdoc.org/">phpDocumentor 2.0.0a7</a> and<br>
            generated on 2012-07-06T18:53:43-05:00.<br></footer></div>
</div>
</body>
</html>
